<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class banners extends MY_Model{
    public function __construct() {
        parent::__construct();
    }
    
    public function addBanner($fields = array()){
        if(empty($fields)){
            return false;
        }
        $this->db->insert('banners',$fields);
        
        return $this->db->insert_id();
    }
   
    //get categories
    public function getBanners($conditions=array(),$limited=false){
       if($limited)
       $this->db->limit($limited);
       $this->db->order_by('id');
        if(empty($conditions))
            $query = $this->db->get('banners');
        else
            $query = $this->db->get_where('banners',$conditions);
       
        if(isset($conditions['id']))
            return $query->row();
        return $query->result();
    }
    
    //update category
    public function update_banner($field=array(),$conditions = array())
    {
        if(empty($field) || empty($conditions)){
            
            return false;
        }
        $this->db->update('banners',$field,$conditions);
        return $this->db->affected_rows();
    }
    
    //delete category
    public function delete_banner($id=false)
    {
        if($id){
            $this->db->where('id',$id);
            $this->db->delete('banners');
        }        
        return $this->db->affected_rows();
        
    }
}
?>
